<%-- 
    Document   : login
    Created on : Jan 10, 2013, 4:19:28 PM
    Author     : SONY
--%>

<%@page import="javax.servlet.http.HttpServletRequest"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<% 
    if(session.getAttribute("user_member") != null) {
        session.removeAttribute("user_member"); 
    } 
%>
<p><i style='color:red'>${requestScope.errorMsg}</i></p>
<form method='post' action='<c:url value="/member/login.do" />'>
<fieldset id="login">
<legend class="lgend">Thông Tin Đăng Nhập</legend>
    <table cellpadding="10px" border="0">
        <tr>
            <td>Email của bạn</td>
<% 
    String email = "";
    String password = "";
    Cookie[] allCookies = ((HttpServletRequest) request).getCookies(); 
    for(int i = 0; i < allCookies.length; i++) {
        if(allCookies[i].getName().equals("email")) {
            email = allCookies[i].getValue();
        }
        if(allCookies[i].getName().equals("password")) {
            password = allCookies[i].getValue();
        }
    }
    if(request.getAttribute("email") != null) {
        email = request.getAttribute("email").toString();
    }     
    if(request.getAttribute("password") != null) {
        password = request.getAttribute("password").toString();
    }     
%>
<td><input type='text' name='email' class="txtMask" value="<%=email%>"
                       <% if(email.length() == 0) { %>
                            style="background-color: white;width: 200px;"
                       <% } else { %>
                            style="background-color: LightYellow;width: 200px;"
                       <% } %>
                       /></td>
        </tr>
        <tr>
            <td>Mật Khẩu</td>
            <td><input type='password' name='password' class="txtMask" value="<%=password%>"
                       <% if(password.length() == 0) { %>
                            style="background-color: white;width: 200px;"
                       <% } else { %>
                            style="background-color: LightYellow;width: 200px;"
                       <% } %>
                       />&nbsp;&nbsp;
            <a href="#">Quên Mật Khẩu ?</a></td>           
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>               
                <input type="checkbox" name="remember" value="checked" ${cookie.remember.value}/> Nhớ Tài Khoản               
            </td>
        </tr>
    </table>
</fieldset>
        <input style="margin-left: 150px; margin-top: 10px;" type='submit' class="btnMask" name='login' value='Đăng Nhập'>
</form>
